<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>css样式设置</title>
    <script src="https://code.jquery.com/jquery-3.6.4.min.js" integrity="sha256-oP6HI9z1XaZNBrJURtCoUT5SUnxFr8s3BzRl+cbzUq8=" crossorigin="anonymous"></script>
    <style>
        div{
            width: 100px;
            height: 100px;
        }
        div.box1{
            border: 10px pink solid;
        }
        div.box2{
            background-color: darkturquoise;
        }
    </style>
    <script>
        $(function () {
            $div=$("div");
            $("button:first").click(function () {
                $div.addClass("box1 box2");
            });
            $("button:eq(1)").click(function () {
                $div.removeClass("box1");
            });
            $("button:eq(2)").click(function () {
                $div.toggleClass("box1 box2");
            });
            $("button:eq(3)").click(function () {
                var x=$div.offset();
                console.log(x);
                $div.offset({
                    top:100,
                    left:100
                });
            });
        });

    </script>
</head>
<body>
        <div></div>
        <button>按钮1</button>
        <button>按钮2</button>
        <button>按钮3</button>
        <button>按钮4</button>
</body>
</html>